<?php
/**
 *
 * Created by IntelliJ IDEA.
 * User: XD
 * Date: 2017/8/22
 * Time: 9:46
 */
namespace namesapcename;
class classnmae
{
    function __construct()
    {
        echo __METHOD__,"\n";
    }

}

function funcname(){
    echo __FUNCTION__,"\n";
}
const constname = "namespaced";

include 'example1.php';

 $a = 'classnmae';
 $obj = new $a;   //// prints classname::__construct
 $b = 'funcname';
 echo constant('constname'),"\n";  //prints glibal

/* note that if using double quotes, "\\namespacename\\classname" must be used */
$a = '\namespacename\classname';
$obj = new $a; // prints namespacename\classname::__construct
$a = 'namespacename\classname';
$obj = new $a; // also prints namespacename\classname::__construct
$b = 'namespacename\funcname';
$b(); // prints namespacename\funcname
$b = '\namespacename\funcname';
$b(); // also prints namespacename\funcname
echo constant('\namespacename\constname'), "\n"; // prints namespaced
echo constant('namespacename\constname'), "\n"; // also prints namespaced

?>